<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/include/tagLib.jsp" %>
<!doctype html>
<html lang="en">
<head>
    <title>${sieName}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <%@include file="/include/cssLib.jsp" %>
    <link rel="stylesheet" href="${ctxStatic}/dropzone/dropzone.css " type="text/css">
</head>

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <!-- 菜单 -->
            <tag:nav key="dicExtWords"/>

            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="col-md-10 col-md-offset-1">
                        <div class="card">
                        <div class="card-header">
                            <div class="row">
                                <form id="searchForm" action="${ctx}/adminConsole/dicExtWords/pageList" method="post">
                                    <div class="col-md-2">
                                        <select name="QF__EQ__createBy" class="selectpicker" data-style="select-with-transition" data-live-search="true">
                                            <option value="">操作人</option>
                                            <c:forEach items="${fns:getUserSelectListData()}" var="selectBo">
                                                <option value="${selectBo.value}" ${selectBo.value eq searchCondMap['QF__EQ__createBy']?'selected':''}>${selectBo.text}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <div class="col-md-2">
                                        <input type="text" name="QF__EQ__word" value="${searchCondMap['QF__EQ__word']}" class="form-control clearable" placeholder="关键词"/>
                                    </div>
                                    <div class="col-md-3">
                                        <input type="text" id="rangeCreateDate" name="QF__BW__createTime" value="${searchCondMap['QF__BW__createTime']}" class="form-control" placeholder=" 录入时间"/>
                                    </div>
                                    <div class="col-md-1">
                                        <button type="submit" class="btn btn-twitter"><i class="fa fa-search"></i></button>
                                        <input type="hidden" id="pageNo" name="pageNo"/>
                                        <input type="hidden" id="pageSize" name="pageSize" />
                                        <input type="hidden" id="orderBy" name="page.orderBy" value="${orderBean.orderBy}"/>
                                        <input type="hidden" id="order" name="page.order" value="${orderBean.order}"/>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="card-content">
                            <div class="toolbar">
                                <div class="input-group col-md-8">
                                    <div class="form-group label-floating is-empty">
                                        <tag:paging-simple page="${pageResult}"/>
                                        <c:if test="${fns:isAdmin()}">
                                        &nbsp;&nbsp;&nbsp;&nbsp;
                                        <button id="importBtn" class="btn btn-success" data-toggle="tooltip" data-placement="right" title="TXT格式，每行为一个词">导入词库</button>
                                        </c:if>
                                    </div>
                                </div>
                            </div>
                            <div class="material-datatables table-responsive">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>关键词</th>
                                        <th>创建者</th>
                                        <th sort-field="create_time">录入时间</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${pageResult.result }" var="data">
                                        <tr>
                                            <td>${data.word}</td>
                                            <td>${data.createByName}</td>
                                            <td>${fns:formatDateTime(data.createTime)}</td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                            <tag:paging page="${pageResult}"/>
                        </div>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="/include/sidebarRight.jsp" %>
</body>
<%@include file="/include/scriptLib.jsp" %>
<script type="text/javascript" src="${ctxStatic}/dropzone/dropzone.js"></script>
<script type="text/javascript">
    $(document).ready(function() {

        //绑定排序
        FormUtil.bindOrder();

        //日期时间范围
        laydate.render({
            elem: '#rangeCreateDate'
            ,type: 'datetime'
            ,max: 0
            ,range: true
        });

        $("[data-toggle='tooltip']").tooltip();
    });

    // 上传插件(改动过源码，更新版本请注意)
    $("#importBtn").dropzone({
        url: ctx+"/adminConsole/dicExtWords/importWords",
        dictDefaultMessage: '请上传txt的词库，每行为一个词',
        hideInputId: "#attachmentUrl",  //隐藏输入框
        hideInputSeparator: ",",	//多值 分割值
        previewsHide: true,
        maxFiles: 1,	//上传文件数
        maxFilesize: 8, //MB 单文件最大体积
        acceptedFiles: ".txt",	//支持类型
        init: function() {
            this.on("success", function(file, responseText, e) {
                var result = eval("("+responseText+")");
//                log(result);
                dialogCenterTopTip(result.message, (result.statusCode != 200?'danger':'success'))
                this.removeAllFiles();
                $("#importBtn").tooltip('hide');
            });
        }
    });
</script>
</html>